package com.itheima.innerclass.test6;

public class TestSwimming {
    public static void main(String[] args) {
        goSwimming(new Swimming() {
            @Override
            public void swim() {
                System.out.println("铁子,咱们去游泳吧");
            }
        });
        //理解: Lambda表达式,对匿名类进行了优化
        goSwimming(() -> System.out.println("铁子,咱们去游泳吧"));

        goSwimming(new SwimmingImpl());
    }

    public static void goSwimming(Swimming swimming){
        //Swimming swimming = new SwimmingImpl();
        /*
        * Swimming swimming = new Swimming(){
        *                       @Override
        *                       public void swim(){
        *                           System.out.println("铁子,咱们去游泳吧");
        *                       }
        *
        *                     }
        *
        **/
        swimming.swim();
    }
}

interface Swimming{
    void swim();
}

class SwimmingImpl implements Swimming{

    @Override
    public void swim() {
        System.out.println("一起游泳吧!");
    }
}